:root {
  --primary: #667eea;
  --secondary: #764ba2;
  --accent: #f093fb;
  --text: #2d3748;
  --text-light: #718096;
  --glass-bg: rgba(255, 255, 255, 0.25);
  --glass-border: rgba(255, 255, 255, 0.18);
  --shadow-light: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  --shadow-heavy: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  margin: 0;
  background: var(--gradient-bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}
.container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2rem;
  backdrop-filter: blur(10px);
  background: var(--glass-bg);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-light);
}

.hero {
  margin-bottom: 2rem;
  text-align: center;
  padding: 2rem 0;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.lead {
  color: var(--text-light);
  margin-top: 0.5rem;
  font-size: 1.2rem;
  font-weight: 400;
}
.flipbook {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

.viewport {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 2rem;
  min-height: 500px;
  box-shadow: var(--shadow-heavy);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.viewport:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
}

.frame {
  position: absolute;
  inset: 0;
  padding: 2rem;
  display: none;
  overflow: auto;
  opacity: 0;
  transform: translateX(30px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Show frames based on radio selection with enhanced animations */
#f1:checked ~ .flipbook .viewport .f1,
#f2:checked ~ .flipbook .viewport .f2,
#f3:checked ~ .flipbook .viewport .f3,
#f4:checked ~ .flipbook .viewport .f4,
#f5:checked ~ .flipbook .viewport .f5 {
  display: block;
  opacity: 1;
  transform: translateX(0);
  animation: slideInFade 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInFade {
  0% {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
  }
  50% {
    opacity: 0.7;
    transform: translateX(10px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Add a subtle pulse animation to active elements */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Loading animation for images */
.frame-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: block;
  margin-top: 1.5rem;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              filter 0.3s ease;
  position: relative;
}

.frame-image::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255, 255, 255, 0.4) 50%, 
    transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
  border-radius: 15px;
}

.frame-image:hover::before {
  transform: translateX(100%);
}

.frame-image:hover {
  transform: scale(1.03) rotate(1deg);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
  filter: brightness(1.1) contrast(1.05);
}

/* Add floating animation to the viewport */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.viewport {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 2rem;
  min-height: 500px;
  box-shadow: var(--shadow-heavy);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation: float 6s ease-in-out infinite;
}

.viewport:hover {
  transform: translateY(-8px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2), 0 15px 25px rgba(0, 0, 0, 0.15);
  animation-play-state: paused;
}

.frame h2 {
  margin: 0 0 1rem 0;
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0;
  transform: translateY(20px);
  animation: slideInText 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s forwards;
}

.frame p {
  margin: 0 0 1.5rem 0;
  color: var(--text-light);
  font-size: 1.1rem;
  line-height: 1.7;
  opacity: 0;
  transform: translateY(20px);
  animation: slideInText 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.4s forwards;
}

@keyframes slideInText {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dots Navigation */
.dots {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dot {
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  color: var(--text);
  position: relative;
  overflow: hidden;
}

.dot::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--gradient-primary);
  transition: left 0.3s ease;
  z-index: -1;
}

.dot:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
  color: white;
}

.dot:hover::before {
  left: 0;
}

.dot:focus,
.dot:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.6);
  outline-offset: 3px;
}

/* Active dot styling */
#f1:checked ~ .flipbook .dots .dot[for="f1"],
#f2:checked ~ .flipbook .dots .dot[for="f2"],
#f3:checked ~ .flipbook .dots .dot[for="f3"],
#f4:checked ~ .flipbook .dots .dot[for="f4"],
#f5:checked ~ .flipbook .dots .dot[for="f5"] {
  background: var(--gradient-primary);
  color: white;
  transform: scale(1.2);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

/* Single Prev/Next Navigation */
.nav-single {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding: 0 1rem;
  position: relative;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border-radius: 25px;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  position: absolute;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  user-select: none;
}

.nav-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
  background: var(--gradient-primary);
  color: white;
}

.nav-btn:active {
  transform: scale(0.95);
}

.prev-btn {
  left: 0;
}

.next-btn {
  right: 0;
}

/* Show appropriate navigation buttons based on current frame */
/* Frame 1: only show next */
#f1:checked ~ .flipbook .nav-single .next-to-f2 {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

/* Frame 2: show both prev and next */
#f2:checked ~ .flipbook .nav-single .prev-to-f1 {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
#f2:checked ~ .flipbook .nav-single .next-to-f3 {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

/* Frame 3: show both prev and next */
#f3:checked ~ .flipbook .nav-single .prev-to-f2 {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
#f3:checked ~ .flipbook .nav-single .next-to-f4 {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

/* Frame 4: show both prev and next */
#f4:checked ~ .flipbook .nav-single .prev-to-f3 {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
#f4:checked ~ .flipbook .nav-single .next-to-f5 {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

/* Frame 5: only show prev */
#f5:checked ~ .flipbook .nav-single .prev-to-f4 {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

/* hide raw radio controls */
.controls {
  position: absolute;
  left: -9999px;
}

/* hide the radio inputs (they are placed as siblings of .flipbook) */
input[type="radio"][name="frame"] {
  position: absolute;
  left: -9999px;
}

.dot:focus,.dot:focus-visible{outline:3px solid rgba(102, 126, 234, 0.6);outline-offset:3px}

/* show frames based on radio selection */
#f1:checked ~ .flipbook .viewport .f1,
#f2:checked ~ .flipbook .viewport .f2,
#f3:checked ~ .flipbook .viewport .f3,
#f4:checked ~ .flipbook .viewport .f4,
#f5:checked ~ .flipbook .viewport .f5{display:block}

/* show appropriate prev/next labels — simpler approach: all labels act, but we can visually hide duplicates */

/* Responsive Design */
@media (max-width: 1024px) {
  .container {
    margin: 1rem;
    padding: 1.5rem;
  }
  
  .hero h1 {
    font-size: 2.5rem;
  }
  
  .flipbook {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .viewport {
    min-height: 450px;
  }
}

@media (max-width: 768px) {
  .container {
    margin: 0.5rem;
    padding: 1rem;
  }
  
  .hero {
    padding: 1rem 0;
    margin-bottom: 1.5rem;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
  
  .lead {
    font-size: 1rem;
  }
  
  .viewport {
    padding: 1.5rem;
    min-height: 400px;
  }
  
  .frame {
    padding: 1.5rem;
  }
  
  .frame h2 {
    font-size: 1.5rem;
  }
  
  .frame-image {
    height: 250px;
  }
  
  .dots {
    gap: 0.5rem;
    padding: 0.75rem;
    flex-wrap: wrap;
  }
  
  .dot {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 0.9rem;
  }
  
  .nav .prev,
  .nav .next {
    width: 3rem;
    height: 3rem;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .container {
    margin: 0.25rem;
    padding: 0.75rem;
  }
  
  .hero h1 {
    font-size: 1.75rem;
  }
  
  .lead {
    font-size: 0.95rem;
  }
  
  .viewport {
    padding: 1rem;
    min-height: 350px;
  }
  
  .frame {
    padding: 1rem;
  }
  
  .frame h2 {
    font-size: 1.25rem;
  }
  
  .frame p {
    font-size: 1rem;
  }
  
  .frame-image {
    height: 200px;
    margin-top: 1rem;
  }
  
  .dots {
    gap: 0.4rem;
    padding: 0.5rem;
  }
  
  .dot {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.8rem;
  }
  
  .nav {
    margin-top: 1rem;
  }
  
  .nav .prev,
  .nav .next {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 0.9rem;
  }
  
  .hint {
    font-size: 0.85rem;
    padding: 0.75rem;
  }
  
  .foot {
    margin-top: 2rem;
    padding: 1.5rem;
    font-size: 0.9rem;
  }
}

/* High DPI and Retina Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .frame-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Dark mode preference support */
@media (prefers-color-scheme: dark) {
  .container {
    background: rgba(0, 0, 0, 0.3);
  }
  
  .viewport {
    background: rgba(0, 0, 0, 0.4);
    color: #e2e8f0;
  }
  
  .frame h2 {
    color: #f7fafc;
  }
  
  .dots {
    background: rgba(0, 0, 0, 0.2);
  }
  
  .dot {
    background: rgba(0, 0, 0, 0.3);
    color: #e2e8f0;
  }
  
  .foot {
    background: rgba(0, 0, 0, 0.2);
  }
  
  .hint {
    background: rgba(0, 0, 0, 0.1);
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .viewport {
    animation: none;
  }
  
  .frame,
  .frame h2,
  .frame p,
  .dot,
  .nav .prev,
  .nav .next,
  .frame-image {
    animation: none;
    transition: none;
  }
  
  .frame-image:hover {
    transform: none;
  }
  
  .viewport:hover {
    transform: none;
  }
}

.preview {
  order: 3;
}

.preview img {
  width: 100%;
  height: auto;
  border-radius: 15px;
  display: block;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.foot {
  margin-top: 3rem;
  text-align: center;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-light);
  font-size: 1rem;
}

.hint {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-top: 1rem;
  text-align: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-style: italic;
}

.small {
  color: var(--text-light);
  font-size: 0.9rem;
}

code {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}